﻿using System;
using System.Collections.Generic;
using System.Text;
using LispInterpretor.HelperClasses;

namespace LispInterpretor.InBuiltProcedures.LogicalOperators
{
    class And : Procedure
    {
        public override object Apply(params object[] args)
        {
            Check.IsTrue(args.Length > 1, "The \"And\" procedure needs two or more arguments.");

            bool result = true;

            foreach (object arg in args)
            {
                Check.IsTrue(arg is bool, "All arguments to the \"And\" procedure need to be boolean.");

                result &= (bool)arg;
            }

            return result;
        }
    }
}
